using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;

/// <summary>
/// 自定义渲染管线
/// </summary>
public class CustomRenderPipeline :  RenderPipeline
{
    // 是否启用动态批处理、GPU实例化
    bool useDynamicBatching, useGPUInstancing;
    
    // 单个摄像机渲染流程
    CameraRenderer renderer = new CameraRenderer();
    
    public CustomRenderPipeline (bool useDynamicBatching, bool useGPUInstancing, bool useSRPBatcher) {
        this.useDynamicBatching = useDynamicBatching;
        this.useGPUInstancing = useGPUInstancing;
        GraphicsSettings.useScriptableRenderPipelineBatching = useSRPBatcher; // 启用SPR批处理
        GraphicsSettings.lightsUseLinearIntensity = true; // 光照 使用线性空间
    }
    
    /// <summary>
    /// 渲染
    /// </summary>
    /// <param name="context">渲染上下文</param>
    /// <param name="cameras">摄像机</param>
    protected override void Render(ScriptableRenderContext context, Camera[] cameras)
    {
        throw new System.NotImplementedException();
    }

    protected override void Render(ScriptableRenderContext context, List<Camera> cameras)
    {
        // 遍历所有摄像机
        for (int i = 0; i < cameras.Count; i++) 
        {
            renderer.Render(context, cameras[i], useDynamicBatching, useGPUInstancing);
        }
    }
}
